<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=windows-1252">
  </head>
  <body>
    <p>LibRaw: C API<a href="index.html">[back to Index]</a></p>
    <h1>LibRaw: C API</h1>
    <p>LibRaw C API is a wrapper around C++ API; therefore, virtually all
      documentation to C API functions is represented by a set of hyperlinks to
      the corresponding places in the <a href="API-CXX.html">description of C++
        API</a>.</p>
    <p>Contents</p>
    <ol>
      <li><a href="#init">Initialization and de</a><a href="#init">nitialization</a></li>
      <li><a href="#return">Returned values</a></li>
      <li><a href="#dataload">Data loading</a></li>
      <li><a href="#setters">Parameters getters/setters</a></li>
      <li><a href="#utility">Auxiliary Functions</a></li>
      <li><a href="#dcrawemu">Data Postprocessing, Emulation of dcraw Behavior</a>
        <ul>
          <li><a href="#dcrawparams">Setting of Parameters</a></li>
          <li><a href="#emu">Emulation of dcraw Behavior</a></li>
        </ul>
      </li>
      <li><a href="#write">Writing to Output Files</a></li>
      <li><a href="#memwrite">Writing processing results to memory buffer</a></li>
    </ol>
    <p><a name="init"></a></p>
    <h2>Initialization and denitialization</h2>
    <dl>
      <dt>libraw_data_t *libraw_init(unsigned int flags);</dt>
      <dd> The function returns the pointer to the <a href="#API-datastruct.html#libraw_data_t">instance
          of libraw_data_t structure</a>.<br>
        The resultant pointer should be passed as the first argument to all C
        API functions (except for libraw_strerror). <br>
        Returns NULL in case of error, pointer to the structure in all other
        cases. </dd>
      <dt>void libraw_close(libraw_data_t *);</dt>
      <dd> Closes libraw_data_t handler and deallocates all memory. </dd>
    </dl>
    <p><a name="return"></a></p>
    <h2>Returned values</h2>
    <p>Functions of C API return EINVAL (see errno.h) if the null pointer was
      passed to them as the first argument. In all other cases, the <a href="API-CXX.html#return">C++
        API return code</a> is returned.</p>
    <p><a name="dataload"></a></p>
    <h2>Data Loading from a File/Buffer</h2>
    <dl>
      <dt>int libraw_open_file(libraw_data_t*, const char *)</dt>
      <dt>int libraw_open_file_ex(libraw_data_t*, const char *,INT64
        bigfile_size)</dt>
      <dt>WIN32: int libraw_open_wfile(libraw_data_t*, const wchar_t *)</dt>
      <dt>WIN32: int libraw_open_wfile_ex(libraw_data_t*, const wchar_t *,INT64
        bigfile_size)</dt>
      <dd>See <a href="API-CXX.html#open_file">LibRaw::open_file()</a></dd>
      <dt>int libraw_open_buffer(libraw_data_t*, void *buffer, size_t bufsize)</dt>
      <dd>See <a href="API-CXX.html#open_buffer">LibRaw::open_buffer()</a></dd>
      <dt>int libraw_open_bayer(libraw_data_t *lr, unsigned char *data, unsigned
        datalen, ushort _raw_width, ushort _raw_height, ushort _left_margin,
        ushort _top_margin, ushort _right_margin, ushort _bottom_margin,
        unsigned char procflags, unsigned char bayer_battern, unsigned
        unused_bits, unsigned otherflags, unsigned black_level)</dt>
      <dd>See <a href="API-CXX.html#open_bayer">LibRaw::open_bayer()</a></dd>
      <dt>int libraw_unpack(libraw_data_t*);</dt>
      <dd>See <a href="API-CXX.html#unpack">LibRaw::unpack()</a></dd>
      <dt>int libraw_unpack_thumb(libraw_data_t*);</dt>
      <dd>See <a href="API-CXX.html#unpack_thumb">LibRaw::unpack_thumb()</a></dd>
      <dt>int libraw_unpack_thumb_ex(libraw_data_t*,int);</dt>
      <dd>See <a href="API-CXX.html#unpack_thumb_ex">LibRaw::unpack_thumb_ex()</a></dd>
    </dl>
    <p><a name="setters"></a></p>
    <h2>Parameters setters/getters</h2>
    <p>These functions provides interface to imgdata.params, .sizes and .color
      fields which works regardless of LibRaw versions used when building
      calling app and the library itself.</p>
    <ul>
      <li>int libraw_get_raw_height(libraw_data_t *lr); </li>
      <li>int libraw_get_raw_width(libraw_data_t *lr); </li>
      <li>int libraw_get_iheight(libraw_data_t *lr); </li>
      <li>int libraw_get_iwidth(libraw_data_t *lr); </li>
      <li>float libraw_get_cam_mul(libraw_data_t *lr,int index); </li>
      <li>float libraw_get_pre_mul(libraw_data_t *lr,int index); </li>
      <li>float libraw_get_rgb_cam(libraw_data_t *lr,int index1, int index2);</li>
      <li>libraw_iparams_t *libraw_get_iparams(libraw_data_t *lr);</li>
      <li>libraw_lensinfo_t *libraw_get_lensinfo(libraw_data_t *lr);</li>
      <li>libraw_imgother_t *libraw_get_imgother(libraw_data_t *lr);</li>
      <li>int libraw_get_color_maximum(libraw_data_t *lr); </li>
      <li>void libraw_set_user_mul(libraw_data_t *lr,int index, float val);</li>
      <li>void libraw_set_demosaic(libraw_data_t *lr,int value); </li>
      <li>void libraw_set_adjust_maximum_thr(libraw_data_t *lr,float value); </li>
      <li>void libraw_set_output_color(libraw_data_t *lr,int value); </li>
      <li>void libraw_set_output_bps(libraw_data_t *lr,int value);</li>
      <li>void libraw_set_gamma(libraw_data_t *lr,int index, float value);</li>
      <li>void libraw_set_no_auto_bright(libraw_data_t *lr,int value);</li>
      <li>void libraw_set_bright(libraw_data_t *lr,float value);</li>
      <li>void libraw_set_highlight(libraw_data_t *lr,int value);</li>
      <li>void libraw_set_fbdd_noiserd(libraw_data_t *lr,int value);</li>
      <li>int  libraw_adjust_to_raw_inset_crop(libraw_data_t *lr, unsigned mask, float maxcrop);</li>
    </ul>
    <p><a name="utility"></a></p>
    <h2>Auxiliary Functions</h2>
    <dl>
      <dt>const char* libraw_version()</dt>
      <dd>See <a href="API-CXX.html#version">LibRaw::version()</a></dd>
      <dt>int libraw_versionNumber()</dt>
      <dt>See <a href="API-CXX.html#versionNumber">LibRaw::versionNumber()</a><br>
      </dt>
      <dd>See <a href="API-CXX.html#versionNumber">LibRaw::versionNumber()</a></dd>
      <dt>bool LIBRAW_CHECK_VERSION(major,minor,patch)</dt>
      <dd>See <a href="API-CXX.html#LIBRAW_CHECK_VERSION">LIBRAW_CHECK_VERSION</a></dd>
      <dt>unsigned libraw_capabilities()</dt>
      <dd>See <a href="API-CXX.html#capabilities">LibRaw::capabilities()</a></dd>
      <dt>int libraw_cameraCount()</dt>
      <dd>See <a href="API-CXX.html#cameraCount">LibRaw::cameraCount()</a></dd>
      <dt>const char* libraw_cameraList()</dt>
      <dd>See <a href="API-CXX.html#cameraList">LibRaw::cameraList()</a></dd>
      <dt>int libraw_get_decoder_info(libraw_data_t*,libraw_decoder_info_t *);</dt>
      <dd>See <a href="API-CXX.html#get_decoder_info">LibRaw::get_decoder_info()</a></dd>
      <dt>const char* libraw_unpack_function_name(libraw_data_t*);</dt>
      <dd>See <a href="API-CXX.html#unpack_function_name">LibRaw::unpack_function_name()</a></dd>
      <dt>int libraw_COLOR(libraw_data_t*,int row,int col);</dt>
      <dd>See <a href="API-CXX.html#COLOR">LibRaw::COLOR()</a></dd>
      <dt>void libraw_subtract_black(libraw_data_t*);</dt>
      <dd>See <a href="API-CXX.html#add_subtract_black">LibRaw::subtract_black()</a></dd>
      <dt>void libraw_recycle_datastream(libraw_data_t*);</dt>
      <dd>See <a href="API-CXX.html#recycle_datastream">LibRaw::recycle_datastream()</a></dd>
      <dt>void libraw_recycle(libraw_data_t*);</dt>
      <dd>See <a href="API-CXX.html#recycle">LibRaw::recycle()</a></dd>
      <dt>const char *libraw_strerror(int errorcode);</dt>
      <dd>See <a href="API-CXX.html#libraw_strerror">LibRaw::strerror</a></dd>
      <dt>const char *libraw_strprogress(enum LibRaw_progress);</dt>
      <dd>See <a href="API-CXX.html#strprogress">LibRaw::strprogress</a></dd>
      <dt>void libraw_set_dataerror_handler(libraw_data_t*,data_callback func,
        void *);</dt>
      <dd>See <a href="API-CXX.html#dataerror">LibRaw::set_dataerror_handler()</a></dd>
      <dt>void libraw_set_progress_handler(libraw_data_t*,progress_callback
        func, void *);</dt>
      <dd>See <a href="API-CXX.html#progress">LibRaw::set_progress_handler()</a></dd>
    </dl>
    <p><a name="dcrawemu"></a></p>
    <h2>Data Postprocessing, Emulation of dcraw Behavior</h2>
    <p><a name="dcrawparams"></a></p>
    <h3>Setting of Parameters</h3>
    <p>The postprocessing parameters for the calls described below are set, just
      as for C++ API, via setting of fields in the libraw_output_params_t
      structure:</p>
    <pre> libraw_data_t *ptr = libraw_init(0);
 ptr-&gt;params.output_tiff = 1; //  output to TIFF
    </pre>
    <p>Fields of this structure are described in the <a href="API-datastruct.html#libraw_output_params_t">documentation
        to libraw_output_params_t</a>. For notes on their use, see <a href="API-notes.html">API
        notes</a>.</p>
    <p><a name="emu"></a></p>
    <h3>Emulation of dcraw Behavior</h3>
    <dl>
      <dt>int libraw_raw2image(libraw_data_t*);</dt>
      <dd>See <a href="API-CXX.html#raw2image">LibRaw::raw2image</a></dd>
      <dt>int libraw_free_image(libraw_data_t*);</dt>
      <dd>See <a href="API-CXX.html#free_image">LibRaw::free_image</a></dd>
      <dt>int libraw_adjust_sizes_info_only(libraw_data_t*);</dt>
      <dd>See <a href="API-CXX.html#adjust_sizes_info_only">LibRaw::adjust_sizes_info_only()</a></dd>
      <dt>int libraw_dcraw_process(libraw_data_t* lr);</dt>
      <dd>See <a href="API-CXX.html#dcraw_process">LibRaw::dcraw_process()</a></dd>
    </dl>
    <h2>Writing to Output Files</h2>
    <dl>
      <dt>int libraw_dcraw_ppm_tiff_writer(libraw_data_t* lr,const char
        *filename);</dt>
      <dd>See <a href="API-CXX.html#dcraw_ppm_tiff_writer">LibRaw::dcraw_ppm_tiff_writer()</a></dd>
      <dt>int libraw_dcraw_thumb_writer(libraw_data_t* lr,const char *fname);</dt>
      <dd>See <a href="API-CXX.html#dcraw_thumb_writer">LibRaw::dcraw_thumb_writer()</a></dd>
    </dl>
    <h2>Writing processing results to memory buffer</h2>
    <dl>
      <dt>libraw_processed_image_t *libraw_dcraw_make_mem_image(libraw_data_t*
        lr,int * errcode)</dt>
      <dd>See <a href="API-CXX.html#dcraw_make_mem_image">LibRaw::dcraw_make_mem_image()</a></dd>
      <dt>libraw_processed_image_t *libraw_dcraw_make_mem_thumb(libraw_data_t*
        lr,int * errcode)</dt>
      <dd>See <a href="API-CXX.html#dcraw_make_mem_thumb">LibRaw::dcraw_make_mem_thumb()</a></dd>
      <dt>void libraw_dcraw_clear_mem(libraw_processed_image_t *);</dt>
      <dd>See <a href="API-CXX.html#dcraw_clear_mem">LibRaw::dcraw_clear_mem()</a></dd>
      <dd><br>
      </dd>
    </dl>
    <p><a href="index.html">[back to Index]</a></p>
  </body>
</html>
